package com.lingchen.boot.gof.observer;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by lc on 2020/6/22
 */
public class Clock {

    private List<AbstrackInfo> infos = new ArrayList<AbstrackInfo>();


    public void say() {
        System.out.println("上班了");
        update();
    }

    public void update() {
        for (AbstrackInfo info : infos) {
            info.message();
        }

    }

    public void add(AbstrackInfo info){
        infos.add(info);
    }


    public static void main(String[] args) {
        Clock clock = new Clock();

        EatInfo eat = new EatInfo();
        SleepInfo sp = new SleepInfo();

        clock.add(eat);
        clock.add(sp);

        clock.say();

    }
}
